{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python37864bit9859aadc2f9b4163a401bc1d107b5e60",
   "display_name": "Python 3.7.8 64-bit"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      " 1   1    1\n 2   4    8\n 3   9   27\n 4  16   64\n 5  25  125\n 6  36  216\n 7  49  343\n 8  64  512\n 9  81  729\n10 100 1000\n"
     ]
    }
   ],
   "source": [
    "'''\n",
    "rjust(), ljust(), center()， zfill() \n",
    "'''\n",
    "\n",
    "for x in range(1,11):\n",
    "    print(repr(x).rjust(2), repr(x*x).rjust(3), end = ' ' )\n",
    "    print(repr(x*x*x).rjust(4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'00012'"
      ]
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "source": [
    "'12'.zfill(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'-003.14'"
      ]
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "'-3.14'.zfill(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'3.1415926234234'"
      ]
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "'3.1415926234234'.zfill(5) # 数字长度长于参数值，按数字长度显示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'000000000000000000000000000000000003.1415926234234'"
      ]
     },
     "metadata": {},
     "execution_count": 11
    }
   ],
   "source": [
    "'3.1415926234234'.zfill(50)"
   ]
  }
 ]
}